package com.xwn.utils.core;

import org.apache.commons.net.ftp.FTPClient;

import java.io.IOException;
import java.net.SocketException;

/**
 * @Author duandw
 * @Date 2019/12/31 18:04
 **/
public class FTPClientWithInfos extends FTPClient {
    private String host;
    private int port;
    private String username;
    private String password;
    private String ftpCharset;

    public FTPClientWithInfos() {
    }

    public String getHost() {
        return this.host;
    }

    public int getPort() {
        return this.port;
    }

    public String getUsername() {
        return this.username;
    }

    public String getPassword() {
        return this.password;
    }

    public String getFtpCharset() {
        return this.ftpCharset;
    }

    public void connect(String hostname, int port) throws SocketException, IOException {
        super.connect(hostname, port);
        this.host = hostname;
        this.port = port;
    }

    public boolean login(String username, String password) throws IOException {
        boolean b = super.login(username, password);
        this.username = username;
        this.password = password;
        return b;
    }

    public void setControlEncoding(String encoding) {
        super.setControlEncoding(encoding);
        this.ftpCharset = encoding;
    }
}